package com.augrain.microframework.core.exception;

import com.augrain.microframework.core.consts.HttpStats;
import lombok.Getter;
import lombok.Setter;

/**
 * 应用异常
 *
 * @author biaoy
 * @since 2020/11/26 0026
 */
@Getter
@Setter
public class ApplicationException extends RuntimeException {

    /**
     * code
     */
    private final Integer code;

    /**
     * data
     */
    private final Object data;

    /**
     * 构造函数
     *
     * @param code
     * @param message
     * @param data
     * @param cause
     */
    public ApplicationException(Integer code, String message, Object data, Exception cause) {
        super(message, cause);
        this.code = code;
        this.data = data;
    }

    /**
     * 构造函数
     *
     * @param code
     * @param message
     * @param data
     */
    public ApplicationException(Integer code, String message, Object data) {
        super(message);
        this.code = code;
        this.data = data;
    }

    /**
     * 构造函数
     *
     * @param code
     * @param message
     */
    public ApplicationException(Integer code, String message) {
        this(code, message, null);
    }

    /**
     * 构造函数
     */
    public ApplicationException(String message) {
        this(HttpStats.HTTP_INTERNAL_ERROR, message, null);
    }

}
